﻿using System.Collections.Generic;
using Gameplay.PVE.Utils;
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
using Yoozoo.Mars.Got.SpriteAnim;

namespace Yoozoo.Gameplay.RTS
{
    /// <summary>
    /// 小兵行为数据
    /// </summary>
    public struct ChildBehaviourNativeData
    {
        public int count;

        public bool inited;

        /// <summary>
        /// 是否有效
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<bool> valid;
        
        /// <summary>
        /// 在方阵中的索引
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<int> index;
        /// <summary>
        /// 在方阵中的位置索引 用来不同方向所处的偏移位置
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<int> postionIndex;

        [NativeDisableParallelForRestriction]
        public NativeArray<float3> position;

        [NativeDisableParallelForRestriction]
        public NativeArray<float3> forward;

        [NativeDisableParallelForRestriction]
        public NativeArray<int> direction;
        
        [NativeDisableParallelForRestriction]
        public NativeArray<float3> targetForward;

        [NativeDisableParallelForRestriction]
        public NativeArray<int> targetDirection;
        
        
        //序列帧相关
        [NativeDisableParallelForRestriction]
        public NativeArray<int> animSpriteIndex;
        [NativeDisableParallelForRestriction]
        public NativeArray<int> shadowSpriteIndex;

        //序列帧数据
        [NativeDisableParallelForRestriction]
        public NativeArray<ChildToSpriteData> animSpriteData;

        [NativeDisableParallelForRestriction]
        public NativeArray<float> alpha;

        [NativeDisableParallelForRestriction]
        public NativeArray<int> animPSIndex;
        [NativeDisableParallelForRestriction]
        public NativeArray<int> shadowPSIndex;
        
        //通用
        [NativeDisableParallelForRestriction]
        public NativeArray<int> state;

        [NativeDisableParallelForRestriction]
        public NativeArray<int> subState;
        
        [NativeDisableParallelForRestriction]
        public NativeArray<int> soldierType;

        [NativeDisableParallelForRestriction]
        public NativeArray<int> soldierId;
        
        //小兵变阵相关

        /// <summary>
        /// 小兵变阵起始位置
        /// 抛飞时表示抛飞起始位置
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float3> startMovePosition;
        
        /// <summary>
        /// 小兵变阵目标位置
        /// 抛飞时x抛飞水平速度，y抛飞高度，z抛飞加速度
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float3> targetMovePosition;
        
        /// <summary>
        /// 小兵变阵目标位置
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float3> childTargetPosition;
        
        /// <summary>
        /// 变阵所需时间
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float> moveNeedTime;

        /// <summary>
        /// 开始移动的时间
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float> moveStartTime;
        
        /// <summary>
        /// 开始旋转的时间
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float> rotateStartTime;
        
        /// <summary>
        /// 是否处于变阵状态
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<bool> InAdjustPositionState;
        
        [NativeDisableParallelForRestriction]
        public NativeArray<bool> IsFirstChange;

        //战斗
        /// <summary>
        /// 战斗某阶段开始时间
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float> stageStartTime;

        /// <summary>
        /// 指令集配表
        /// </summary>
        //public NativeArray<SoldierAttackActionConfig> actionConfigs;
        [NativeDisableParallelForRestriction]
        public NativeArray<int> actionConfigId;

        /// <summary>
        /// 当前执行的指令集id
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<int> instructionSetIndex;

        /// <summary>
        /// 执行行动的等待时间，可以与moveStartTime合并
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<float> waitTime;

        /// <summary>
        /// 指令集里的行动id
        /// </summary>
        [NativeDisableParallelForRestriction]
        public NativeArray<int> actionIndex;
        
        [NativeDisableParallelForRestriction]
        public NativeArray<float3> transformOffset;
        
        //变阵相关
        //[NativeDisableParallelForRestriction] 
        //public NativeArray<ChildMovementData> movementData;
    }
    
}
